I developed a custom cursor routine for some of my stacks which may be useful to others. If you have comments or find bugs please write me:
David R. Waddell
918 Second Street SW
Rochester, MN 55902
email waddell@mayo.edu
CIS 71020,443
These routines use a technique that is independent of HyperCard to switch the cursors regularly.
ANIMATED CURSORS
For animated cursors the command which starts the cursors changing is:
slug 7
The parameter can be between 0 and 7 and is the number of cursors to switch between. The default is 5. I call it inside scripts to make a "busy" cursor.
The command to stop the animated cursor is:
killslug
Since I use it as a busy cursor, I put the following handler into the stack script, or better yet the home stack script:
on idle
killslug
end idle
This will stop it when something unpredictable happens like a script bombing.
In all cases you should put the following handler into the stack script of your stack:
on closeStack
killslug
end closeStack
The install routine in the "install cursor" stack will put this handler as well as everything else that is necessary into your stack.
Customizing animated cursors:
The resources that are used for the animated cursors have ids between 300 and 307. You can customize them using a resource editor like ResEdit from Apple which is available through MAUG libraries. The program can be used to edit graphic resources such as cursors using tools much like MacPaint. Although many parts of the program are easy to use, the ResEdit program can wreck havoc if you are not careful. Use it only with copies of critical programs.
SINGLE CURSORS
Custom single cursors can be produced by a second set of routines. The routine which starts the cursor is
setCursor "name"
or
setCursor "resource id "
This routine can be used to effectively overide the HyperCard cursors outside of executing scripts. HyperCard is still able to change its cursor when you move to areas at which it would normally change, however the HyperCard cursor will be rapidly replaced with your cursor.
To stop this cursor from overiding the HyperCard cursors use the following command:
killCursor
As above, a script should be included in your stack to call this routine before closing the stack. The install stack will do this for you.
Occasionally a cursor gets left on the screen. However, it is not part of your stack and it will disappear when that area of the screen is updated.
For hackers:
The following additional resources are used to switch the cursors:
vbiT id=128
This resource has space for eight cursors which is followed by the routine that is installed as a vertical blanking interval task to switch the cursors.
vbiT id=129
This resource has space for a single cursor. It is installed by the "setCursor" routine.
XCMD: "slug"
This makes a copy of the animated cursors (ids 300-307) and installs them in a copy of the vbiT resource which was made using NewPointer. It then installs it as a vertical blanking interval task and puts a copy of the pointer into the TEMP id=128 resource.
XCMD: "setCursor"
This does the same as slug for a single cursors. It stores its pointer in the TEMP id=129 resource.
XCMD: "killslug"
This gets the pointer in the TEMP id=128 resource and looks to see if it is installed in the queue of vertical blanking interval tasks. If it is there it removes it.
XCMD: "killCursor"
This gets the pointer stored in the TEMP id=129 resource and removes it from the blanking interval queue if it is there.